package com.acmedcare.framework.exchange.center.consumer;

import com.acmedcare.framework.exchange.center.core.handler.ConsumerHandlerMBean;
import com.acmedcare.framework.exchange.center.entity.bean.Consumer;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ConsumerMessageListener {

  final Consumer consumer;
  final ConsumerHandlerMBean consumerHandler;

  public ConsumerMessageListener(
      Consumer consumer,
      ConsumerHandlerMBean consumerHandler) {
    this.consumer = consumer;
    this.consumerHandler = consumerHandler;
  }

  @SuppressWarnings("unused")
  public void invoke(String msg) {

    try {
      consumerHandler.invoke(msg, consumer);
    } catch (Exception e) {
      log.error("消息处理异常" + consumer.getName() + consumer.getPluginName(), e);
    }
  }
}
